package com.TTBook.common;

import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.TTBook.common.queue.AbstractQueue;
import com.TTBook.common.queue.ImageQueue;
import com.TTBook.common.queue.Queue;

public class InitServlet extends HttpServlet{
	public InitServlet()
	{
		super();
	}
	public void init(ServletConfig config) throws ServletException
	{
		WebApplicationContext wac = 
				WebApplicationContextUtils.getRequiredWebApplicationContext(config.getServletContext());
		AbstractQueue imageQueue = new ImageQueue();
		Queue.setImageQueue(imageQueue);
		new Thread((Runnable) imageQueue).start();
	}
	public void destroy()
	{
		
	}
	public ServletConfig getServletConfig()
	{
		return null;
	}
	protected void doGet(HttpServletRequest request , HttpServletResponse response) throws ServletException,IOException{
		doPost(request, response);
	}
	protected void doPost(HttpServletRequest request , HttpServletResponse response) throws ServletException,IOException{
		
	}
}
